/*
 * @Author: ch cwl_ch@163.com
 * @Date: 2022-11-21 17:23:51
 * @LastEditors: ch
 * @LastEditTime: 2022-12-30 16:32:05
 * @Description: file content
 */
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import fs from 'fs';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
  ],
  server: {
    host: '0.0.0.0', // 或者指定你的本机局域网地址 '192.168.56.1'
    port: 3000, // 可自定义端口号
    // 浏览器本地开发代理配置
    proxy: {
      "/api": {
        target: "http://172.172.9.69:8080",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, "/api-passenger")
      },
      "/sseApi": {
        target: "http://172.172.9.62:8091",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/service-sse/, "/")
      },

      "/payApi": {
        target: "https://4601f58c0c21.ngrok-free.app",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/service-pay/, "/")
      },
      "/ai": {
        target: "http://172.172.9.69:8080",
        changeOrigin: true,
        //打印path
        rewrite: (path) => {
          console.log(path)
          return path.replace(/^\/ai/, "/ai")
        }
      },
    },
  },
})
